Top 10k strings from M-Code Library 3 - Interrupt Driven Trace (1985)(16-48 Tape Magazine).z80
in <root> / bin / z80 / software / Sinclair Spectrum Collection TOSEC.exe / Sinclair ZX Spectrum - Utilities & Educational / Sinclair ZX Spectrum - Utilities & Educational - [Z80] (TOSEC-v2007-01-01) /
Back to the directory listing
3 ;"lib3code" 3 )*(l>lc),16 2 PRESS A KEY 2 INTERRUPT DRIVEN TRACE 2 ;"tracecode" 2 ;"library 3" 2 "tracecode" 2 "lib3code" 2 copies.)" 1 z$="10020203 1 z$="04030104 1 z$="01020104 1 wait=65261 1 l=l+(l<max)*(k$="6" 1 bottom right corner of the 1 STOP THE TAPE 1 SAVE""tracecode""CODE 65174,157 1 RUN THE TAPE 1 PUSH HL","Save HL on the stack."," PUSH IX","Push the display address onto the stack."," POP DE","Get the display address off the stack." 1 PRINTING ROUTINE 1 POP IX","Exit from the routine, but firstretrieve..." 1 ON, OFF & VECTOR 1 MAIN ROUTINE pt2 1 MAIN ROUTINE pt1 1 M/CODE LIBRARY 3 1 LET THE TAPE RUN 1 LD A,0FFh","Start with A at -1. We use A to holdthe quotient of HL/BC."," 1 LD A,(HL)","Fetch the next byte of the 1 INTERRUPT TRACER 1 HACKER'S NOTES 1 GENERAL NOTES 1 FEFF A4 Vector to the main FF00 FE routine at FEA4." 1 FEEF Low byte of delay loop 1 FEED Displacement for jump to 1 FEA4 Main routine starts"'" 1 FE9F OFF"'" 1 FE96 ON"'" 1 DIGIT SUBROUTINE 1 DI","Disable interrupts while we are changing mode."," IM1","Back to mode 1."," EI","Enable interupts."," RET","Back to normal basic." 1 ASSEMBLY LISTING 1 ;"library 3": 1 ;"Verified O.K. Press any key. ": 1 ;"Use up and down keys to read thenotes. 1 ;"Some of you may wish to play around with the code a little. These addresses may be useful." 1 ;"Saved and verified O.K. 1 ;"Rewind and play to verify.": 1 ;"Part 10 of our m/code tutor did a fairly thorough job on mode 2 so I will be brief here." 1 ;"For most of the time that this program is running you will see two numbers displayed at the 1 , the start of the interrupt routine." 1 *(l>lc);a$: 1 ) and mode 1 is reselected with 1 '"This machine is currently in interrupt mode 2. The interrupt routine does all the same thingsas the mode 1 routine and then goes on to print the contents ofsystem variables PPC and SUBPCC." 1 '"They are the current line numberand the statement number within the line." 1 '"The code starts at 65174 and is 157 bytes long. Interrupt mode 2is called by 1 '"Programs can be slowed down by using a wait loop in the routineso that very little time is leftbetween the interrupts for the basic program." 1 '"POKE 65261,8 for normal speed." 1 '"POKE 65261,0 for slow motion,": 1 '"(See chapter 25 in the manual. The PLUS guide is hopeless.)" 1 "library 3" 1 "See note.","The code has been positioned so that the main routine ends just before FEFFh(65279) and the two main subroutines follow at FF01." 1 "FEFF DEFB A4","FEFF is the address formed from the Interrupt register and the usual FF on the data bus.","FF00 DEFB FE","These two bytes contain the 1 "23658",o: 1 ","This jump has a displacement of 08 to skip the delay routine. POKE 65261,0 to include the 1 ","Skip the trace if not running a program."," LD IX,50FDh","This is the display address for printing the line number." 1 ","Print units digit." 1 ","Print the units digit."," JR 1 ","Print the tens and return with the units." 1 ","Print the hundreds and return the remainder."," LD BC,10","Now do the tens."," CALL 1 ","Print tens digit and return withunits in HL."," LD A,L","Put units digit in A."," ADD ""0""","Add ASCII for zero to get ASCII for digit."," CALL 1 ","Print hundreds digit and return ready to do tens."," LD BC,10","Prepare for tens digit."," CALL 1 ","If all 8 bytes are not done, do the next one."," INC IX","Advance the screen address to the next character position."," POP HL","Retrieve HL from the stack."," RET","Back where it was called from.","end" 1 ","If HL is still positive go back and see if we can subtract BC once more, if not..."," ADD HL,BC","Restore HL to give the 1 ","Divide HL by BC(line number by 1000), print the quotient and return with the remainder in HL." 1 ","Call the special, fast print routine (next page)."," RET","Return to the main routine.","end" 1 "(300+100* 1 " LD HL,(CHARS)","Load HL from the system variableCHARS (23606) which points to the character set."," LD B,0","The code for the digit goes intoBC; since it is only one byte, the high byte is zero."," LD C,A","BC now holds the code for the digit." 1 " RST 38h","Do the IM1 routine to update theframe counter and read the 1 " RL C","and you have multiplied the codeby 8."," RL B","This is because each character is stored as 8 bytes." 1 " POP HL","all the registers..."," POP DE","from..."," POP BC","the...."," POP AF","stack." 1 " OR A","Reset the carry flag."," RL C","Rotate C throught the carry so that the highest bit..."," RL B","goes into B."," RL C","Do this three times..."," RL B","with effect of doubling BC each time..." 1 " LD L,A","HL now holds the statement 1 " LD IX,50FDh","This is the display address for the statement number."," LD H,0","The statement number is only onebyte, so the high byte is zero."," LD A,(SUBPCC)","Fetch the statement number from the system variable SUBPCC. 1 " LD HL,(PPC)","Load HL from PPC (23621), the systems variable holding the line number."," LD A,H","Transfer the high byte to A."," ADD 216","This will give a carry if the line number is over 9999 becausewe are in immediate BASIC mode." 1 " LD BC,1400H","Load BC with the number times todo the delay loop."," 1 " LD BC,1000d","Prepare to find the thousands digit with the DIGit routine."," CALL 1 " LD BC,100","Prepare to print the hundreds digit."," CALL 1 " LD BC,100","Prepare to print hundreds digit."," CALL 1 " LD A,L","Put the units into A."," ADD ""0""","Add the code for zero to get thecode for the digit." 1 " JR NZ, 1 " JR C, 1 " EI","Enable the interrupts."," RETI","Return to continue with the 1 " EI","Enable interrupts after the 1 " ADD HL,BC","HL now points to the 8 bytes which define the digit."," LD B,8","B counts the 8 bytes onto the screen." 1 " ADD ""0""","Add the code for zero to get thecode for the digit."," CALL 1 to move on, 1 to copy." 1 skip the delay.Contains 8 1 routines follow.)" 1 routine."'" 1 routine." 1 return instruction."," RET","Back to basic with the trace on.","",""," 1 remainder." 1 number (SUBPCC)." 1 keyboard."," DI","Disable the interrupts for the duration of this routine."," PUSH AF","Save the registers."," PUSH BC","Save the registers."," PUSH DE","Save the registers."," PUSH HL","Save the registers."," PUSH IX","Save the registers." 1 interrupt vector in A."," LD I,A","and thence into the Interrupt Register."," IM2","Select mode 2." 1 include the delay." 1 delay, POKE 65261,8 to skip it." 1 counter,"'"FEF0 High byte of same." 1 character."," LD (DE),A","Put the byte on the screen."," INC HL","Point HL at the next byte down."," INC D","Point DE to the next line down on the screen." 1 but is POKEd to 0 to 1 again."," 1 SUBPCC=23623." 1 Press any key.": 1 INC A","Increment the quotient."," SBC HL,BC","Subtract BC from HL"," JR NC, 1 HACKER'S NOTES 1 DI","Disable interrupts while we sortthis out."," LD A,0FEh","Put the high byte of the 1 DEC BC","Decrement the counter."," LD A,B","Put the High byte in A."," OR C","This can only result in zero if both bytes are zero." 1 BASIC program. 1 for tape,"; 1 for microdrive,"; 1 for menu." 1 HOW TO USE IT